import request from '@/utils/request'
export default {
  components: {},
  data() {
    return {
      loading: false,
      visible: false,
      isDetail: false,
      dataForm: {
        id: '',
        followUpMethod: undefined,
        infringementIssue: undefined,
        followUpDate: undefined,
        followUpStatus: undefined,
        followUpDetails: undefined,
        attachments: []
      },
      followUpMethodOptions: [
        {
          enCode: '1',
          fullName: '协商沟通'
        },
        {
          enCode: '2',
          fullName: '激活续费'
        },
        {
          enCode: '3',
          fullName: '工商维权'
        },
        {
          enCode: '4',
          fullName: '侵权诉讼'
        }
      ],
      handlesOptions: [
        {
          enCode: '1',
          fullName: '跟进中'
        },
        {
          enCode: '2',
          fullName: '已完成'
        }
      ],
      violationlssueOptions: [
        {
          enCode: '1',
          fullName: '合同解除，未拆品牌标识'
        },
        {
          enCode: '2',
          fullName: '品牌竞业，违约经营'
        },
        {
          enCode: '3',
          fullName: '贝尔品牌，其他违约'
        },
        {
          enCode: '4',
          fullName: '其它机构侵权'
        }
      ],
      CampusStatusOptions: [],
      rules: {
        followUpMethod: [
          {
            required: true,
            message: '请选择维权方式',
            trigger: 'change'
          }
        ],
        infringementIssue: [
          {
            required: true,
            message: '请输入违规事项',
            trigger: 'blur'
          }
        ],
        followUpDate: [
          {
            required: true,
            message: '请选择跟进时间',
            trigger: 'change'
          }
        ],
        followUpStatus: [
          {
            required: true,
            message: '请选择进状态',
            trigger: 'change'
          }
        ]
      }
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    goBack() {
      this.$emit('refresh')
    },
    init(id) {
      this.dataForm.id = id || 0
      this.visible = true
    },
    dataFormSubmit() {
      this.$refs['elForm'].validate(valid => {
        if (valid) {
          console.log(this.dataForm)
          if (!this.dataForm.id) {
            request({
              url: `/api/campus/violationscases`,
              method: 'post',
              data: this.dataForm
            }).then(res => {
              this.$message({
                message: res.msg,
                type: 'success',
                duration: 1000,
                onClose: () => {
                  this.visible = false
                  this.$emit('refresh', true)
                }
              })
            })
          } else {
            request({
              url: '/api/campus/violationscases/' + this.dataForm.id + '/followup',
              method: 'POST',
              data: this.dataForm
            }).then(res => {
              this.$message({
                message: res.msg,
                type: 'success',
                duration: 1000,
                onClose: () => {
                  this.visible = false
                  this.$emit('refresh', true)
                }
              })
            })
          }
        }
      })
    }
  }
}
